package com.drawing.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.drawing.common.CommonData;
import com.drawing.pojo.IPenetration;
import com.drawing.service.IPService;

/**
 * @author zhaozhenhang <zhaozhenhang@kuaishou.com>
 * Created on 2023-10-15
 */
@RestController
@RequestMapping("/ip")
public class IPController {

    private Logger logger = LoggerFactory.getLogger(IPController.class);

    @Autowired
    private IPService ipService;

    @GetMapping("/network_url")
    public CommonData networkUrl() {
        try {
            IPenetration url = ipService.queryIP();
            return CommonData.success(url.getUrl());
        } catch (Exception e) {
            logger.error("network_url exception: ", e);
            return CommonData.error(e.getMessage());
        }
    }
}
